<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class TagsController extends AppController {
    var $helpers = array('Cache');
    var $layout = 'default';
    var $uses = array(
        'Game', 'Gametags'
    );
    var $cacheAction = array(
        'index' => 1800
    );

    function index($id, $slug) {
        $tag_info = $this->Gametags->getTagInfo($id);
        
        $this->set('title_for_layout', $tag_info['title']);
        $this->set('description_for_layout', $tag_info['description']);
        
        $page = array_key_exists('page', $this->params['named']) ? $this->params['named']['page'] : 1;

        $list_ids = array();
        $conditions = array(
            'Game.published' => 1,
            'Gametags.tag_id' => $id
        );
        $this->paginate = array(
            'fields' => array('Game.id, Game.hot_icon, Game.alias, Game.title, Game.thumbnail, Game.folder_url, Game.play_times'),
            'conditions' => $conditions,
            'limit' => 24,
            'order' => array(
                'Game.id' => 'DESC'
            ),
        );

        $data = $this->paginate('Gametags');
        shuffle($data);

        $this->set('total', $this->params['paging']['Gametags']['count']);
        $this->set('data', $data);
        $this->set('tag_info', $tag_info);
        $this->set('thumbnail_thumb_url_path', Configure::read('game_flash_thumbnail_url_path'));
        $this->set('start_page', $page);
    }
}

?>
